import type { EChartsOption } from "echarts";

interface Interface {
  seriesData1: number[]
  seriesData2: number[]
}

export function getOption(optionData: Interface): EChartsOption{
  const xData = [2018,2019,2020,2021,2022];
  return  {
    grid: {
      left: '5%',
      right: '5%',
      top: '10%',
      bottom: '22%',
      containLabel: true,
    },
    tooltip: {
      show: true,
      trigger: 'axis',
    },
    legend: {
      left:'30%',
      bottom:'10%',
      data: [{
        name: '生产总值',
        textStyle: {
          color: '#ffffff'
        }
      }, {
          name: '税收',
          textStyle: {
            color: '#ffffff'
          }
        },
      ]
    },
    xAxis: [
      {
        type: 'category',
        axisLine: {
          show: true,
          lineStyle: {
            color: '#85C1D9',
          },
        },
        axisTick: {
          show: false,
        },
        axisLabel: {
          color: '#8BC4F2',
          margin: 6,
        },
        splitLine: {
          show: false,
        },
        boundaryGap: ['5%', '5%'],
        data: xData,
      },
    ],
    yAxis: [
      {
        type: 'value',
        axisLabel: {
          color: '#8BC4F2',
        },
        splitLine: {
          lineStyle: {
            color: '#355C84',
            type: 'dashed',
          },
        },
      },
    ],
    series: [
      {
        name: '生产总值',
        type: 'line',
        stack: '总量',
        symbolSize: 6,
        itemStyle: {

          color: {
            type: 'linear',
            x: 0,
            y: 0,
            x2: 1,
            y2: 1,
            colorStops: [{
              offset: 0, color: '#9986c0'
            }, {
              offset: 1, color: '#e17408'
            }]
          }
        },
        data: optionData.seriesData1,
      },
      {
        name: '税收',
        type: 'line',
        stack: '总量',
        symbolSize: 6,
        itemStyle: {
          color: '#5fb878',
          borderColor: '#477bff',
          borderWidth: 2,
        },
        data: optionData.seriesData2,
      },
    ],
  };

}
